package com.gupaoedu.pattern.prototype.shallow;

import com.gupaoedu.pattern.prototype.Course;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 2019/5/12
 * created by chenpp
 */
public class ShallowCloneTest {
    public static void main(String[] args) {
        Student stu = new Student();
        stu.setStudentName("Jane");
        List<Course> list = new ArrayList<Course>();
        Course math = new Course("Math",new Date());
        Course chinese = new Course("Chinese",new Date());
        list.add(math) ;
        list.add(chinese);
        stu.setCourses(list);
        Student cloneStu = (Student) stu.clone();
        cloneStu.getCourses().add(new Course("English",new Date()));
        System.out.println(stu.getCourses().size());
        System.out.println(cloneStu.getCourses()==stu.getCourses());
    }
}
